from tortoise import fields
from .base import BaseModel, TimestampMixin

class Buckling(BaseModel, TimestampMixin):
    order_id = fields.IntField(default=0, description="订单id")
    goods_id = fields.IntField(default=0, description="商品id")
    sku_id = fields.IntField(default=0, description="规格id")
    user_id = fields.IntField(default=0, description="用户id")
    nums = fields.IntField(default=0, description="数量")
    direction = fields.IntField(default=1, max_length=10, description="变动方向1增加2减少")
    add_uid = fields.IntField(default=0, description="录入人id")
    space_id = fields.IntField(default=0, description="门店id")
    use_nums = fields.IntField(default=0, description="使用次数")
    last_nums = fields.IntField(default=0, description="剩余次数")
    price = fields.DecimalField(max_digits=10, decimal_places=2, description="划扣总金额")

    class Meta:
        table = "saas_buckling"

class Cases(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户id")
    add_uid = fields.IntField(default=0, description="录入人id")
    space_id = fields.IntField(default=0, description="门店id")
    desc = fields.CharField(max_length=255,description="备注")
    files = fields.JSONField(null=True, description="关联凭证")
    designer_ids = fields.JSONField(null=True, description="技师ids")
    buckling_data = fields.JSONField(null=True, description="明细")

    class Meta:
        table = "saas_cases"

class BucklingDetail(BaseModel, TimestampMixin):
    buckling_id = fields.IntField(default=0, description="buckling_id")
    cases_id = fields.IntField(default=0, description="病例id")
    nums = fields.IntField(default=0, description="数量")
    buckling_price = fields.DecimalField(max_digits=10, decimal_places=2, description="划扣金额")

    class Meta:
        table = "saas_buckling_detail"

class SchedulingRules(BaseModel, TimestampMixin):
    label = fields.TextField(default="", description="名称", null=True)
    start = fields.TextField(default="", description="开始时间", null=True)
    end = fields.TextField(default="", description="结束时间", null=True)
    color = fields.TextField(default="", description="颜色1", null=True)

    class Meta:
        table = "saas_scheduling_rule"

class SchedulingDates(BaseModel, TimestampMixin):
    rules_id = fields.IntField(default=0, description="rules_id")
    designer_id = fields.IntField(default=0,null=True, description="技师id")
    date = fields.TextField(default="", description="日期", null=True)
    start = fields.TextField(default="", description="开始时间", null=True)
    end = fields.TextField(default="", description="结束时间", null=True)
    space_id = fields.IntField(default=0, description="门店id")

    class Meta:
        table = "saas_scheduling_dates"
